import pygame


class TheRect:
    def __init__(self, x, y, w, h, color, width=0):
        self.x = x
        self.y = y
        self.w = w
        self.h = h
        self.color = color
        self.width = width
        self.c = 'no'
        # self.rect = pygame.Rect(x, y, w, h)

    def move(self, speedx, speedy):
        self.x += speedx
        self.y += speedy

    def get_rect(self):
        return pygame.Rect(self.x, self.y, self.w, self.h)

    def is_collided(self, rect2):
        if pygame.Rect.colliderect(self.get_rect(), rect2.get_rect()) and self.c=='no':
            self.c = 'yes'
            return pygame.Rect.colliderect(self.get_rect(), rect2.get_rect())
        self.c='no'
        return pygame.Rect.colliderect(self.get_rect(), rect2.get_rect())
        # return self.rect.colliderect(rect2.get_rect())

    def draw(self, screen):
        pygame.draw.rect(screen, self.color, self.get_rect(), self.width)
